<template>
  <div class="container">
    <!-- 商品分类侧边栏 -->
    <div class="sidebar">
      <div class="category-header">
        <h3 class="title">商品分类管理</h3>
        <!-- 父组件模板部分 -->
<el-button 
  type="primary" 
  size="small"
  @click="handleAddRootCategory"  
>
  <el-icon><CirclePlus /></el-icon>
  新增根分类
</el-button>
      </div>
      
      <!-- 分类树结构 -->
      <el-tree
        :data="categoryTree"
        node-key="id"
        :indent="24"
        default-expand-all
        :expand-on-click-node="false"
      >
        <template #default="{ data }">
          <span class="category-node">
            <span class="node-label">{{ data.name }}</span>
            <span class="category-actions">
              <el-tooltip content="添加子分类" placement="top">
                <el-button 
                  link 
                  size="small" 
                  @click.stop="handleAddSubCategory(data)"
                />
              </el-tooltip>
              <el-tooltip content="编辑分类" placement="top">
                <el-button 
                  link 
                  type="primary" 
                  size="small"
                  @click.stop="handleEditCategory(data)"
                />
              </el-tooltip>
              <el-tooltip content="删除分类" placement="top">
                <el-button 
                  link 
                  type="danger" 
                  size="small"
                  @click.stop="handleDeleteCategory(data)"
                  :icon="Delete"
                />
              </el-tooltip>
            </span>
          </span>
        </template>
      </el-tree>
    </div>

    <!-- 商品列表主体 -->
    <div class="content">
      <div class="header">
        <!-- 搜索表单 -->
        <div class="search-form">
          <el-form :inline="true" :model="searchForm">
            <el-form-item label="商品编号">
              <el-input 
                v-model="searchForm.goodsNo" 
                placeholder="请输入编号"
                clearable
                suffix-icon="Search"
              />
            </el-form-item>
            <el-form-item label="商品名称">
              <el-input 
                v-model="searchForm.goodsName" 
                placeholder="请输入名称"
                clearable
              />
            </el-form-item>
            <el-form-item label="商品品牌">
              <el-select 
                v-model="searchForm.brand" 
                placeholder="请选择品牌"
                clearable
              >
                <el-option
                  v-for="brand in brandOptions"
                  :key="brand.value"
                  :label="brand.label"
                  :value="brand.value"
                />
              </el-select>
            </el-form-item>
          </el-form>
        </div>

        <!-- 操作按钮组 -->
        <div class="action-buttons">
          <el-button @click="handleReset">重置</el-button>
          <el-button type="primary" @click="handleSearch">查询</el-button>
          <el-button 
            type="success" 
            @click="handleAddGoods"
            :icon="CirclePlus"
          >
            新增商品
          </el-button>
        </div>
      </div>

      <!-- 商品数据表格 -->
      <el-table 
        :data="goodsList" 
        border 
        stripe
        size="small"
        style="width: 100%"
        header-row-class-name="table-header"
        v-loading="loading"
      >
        <el-table-column 
          prop="goodsInfo" 
          label="商品信息" 
          min-width="180"
          sortable
        />
        <el-table-column 
          prop="specs" 
          label="规格信息" 
          width="120"
        />
        <el-table-column 
          prop="price" 
          label="金额（元）" 
          width="120"
          align="right"
        >
          <template #default="{ row }">
            {{ row.price.toFixed(2) }}
          </template>
        </el-table-column>
        <el-table-column 
          prop="weight" 
          label="重量(kg)" 
          width="120"
          align="right"
        />
        <el-table-column 
          prop="dimensions" 
          label="长宽高(cm)" 
          width="150"
        />
        <el-table-column 
          label="操作" 
          width="140" 
          fixed="right"
        >
          <template #default="{ row }">
            <el-button 
              link 
              type="primary" 
              size="small" 
              @click="handleEditGoods(row)"
            >
              编辑
            </el-button>
            <el-button 
              link 
              type="danger" 
              size="small" 
              @click="handleDeleteGoods(row)"
              :icon="Delete"
            >
              删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>

      <!-- 分页组件 -->
      <div class="pagination-container">
        <el-pagination
          background
          layout="total, sizes, prev, pager, next, jumper"
          :page-sizes="[10, 20, 50, 100]"
          :total="total"
          v-model:current-page="currentPage"
          v-model:page-size="pageSize"
          @current-change="handlePageChange"
          @size-change="handleSizeChange"
        />
      </div>
    </div>

    <!-- 新增商品抽屉 -->
    <el-drawer
      v-model="showGoodsDrawer"
      title="新增商品"
      direction="rtl"
      size="85%"
    >
      <el-form :model="goodsForm" label-width="100px" class="goods-form">
        <!-- 基本信息 -->
        <div class="form-section">
          <h4 class="section-title">商品基本信息</h4>
          <el-row :gutter="20">
            <el-col :span="12">
              <el-form-item label="商品名称" prop="name">
                <el-input v-model="goodsForm.name" placeholder="请输入商品名称" clearable />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="商品分类" prop="category">
                <el-select v-model="goodsForm.category" placeholder="请选择分类" clearable>
                  <el-option
                    v-for="item in categories"
                    :key="item.id"
                    :label="item.name"
                    :value="item.id"
                  />
                </el-select>
                <el-button type="text" @click="openCategoryDialog(null)">+新增分类</el-button>
              </el-form-item>
            </el-col>
            
            <el-col :span="12">
              <el-form-item label="商品编号" prop="goodsNo">
                <el-input v-model="goodsForm.goodsNo" placeholder="请输入编号" clearable />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="商品单位" prop="unit">
                <el-input v-model="goodsForm.unit" placeholder="请输入单位类别" clearable />
              </el-form-item>
            </el-col>
            <!-- 新增品牌选择 -->
      <el-col :span="12">
        <el-form-item label="商品品牌" prop="brand">
          <el-select
            v-model="goodsForm.brand"
            placeholder="请选择品牌"
            clearable
            style="width: 100%"
          >
            <el-option
              v-for="item in brandOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
      </el-col>
          </el-row>
        </div>

        <!-- 商品规格信息优化 -->
      <div class="spec-section">
        <div class="section-header">
          <h3 class="section-title">商品规格信息</h3>
          <el-button 
            type="primary" 
            size="small"
            @click="addSpec"
            :icon="CirclePlus"
          >
            添加规格
          </el-button>
        </div>

        <!-- 规格表格容器 -->
        <div class="spec-container">
          <!-- 表格标题 -->
          <div class="spec-header">
            <div class="header-item" style="width:18%">规格名称</div>
            <div class="header-item" style="width:20%">编号/条码</div>
            <div class="header-item" style="width:22%">尺寸(cm)</div>
            <div class="header-item" style="width:18%">重量(kg)</div>
            <div class="header-item" style="width:16%">价格(元)</div>
            <div class="header-item" style="width:6%"></div>
          </div>

          <!-- 规格内容 -->
          <div class="spec-body">
            <div 
              v-for="(spec, index) in goodsForm.specs"
              :key="index"
              class="spec-row"
            >
              <!-- 规格名称 -->
              <div class="spec-cell" style="width:18%">
                <el-input
                  v-model="spec.name"
                  placeholder="请输入"
                  size="small"
                  clearable
                />
              </div>

              <!-- 编号/条码 -->
              <div class="spec-cell" style="width:20%">
                <div class="barcode-group">
                  <el-input
                    v-model="spec.goodsNo"
                    placeholder="编号"
                    size="small"
                    class="mb-2"
                  />
                  <el-input
                    v-model="spec.barcode"
                    placeholder="条码"
                    size="small"
                    clearable
                  >
                    <template #append>
                      <el-icon class="cursor-pointer"><Camera /></el-icon>
                    </template>
                  </el-input>
                </div>
              </div>

              <!-- 尺寸 -->
              <div class="spec-cell" style="width:22%">
                <div class="dimension-group">
                  <el-input-number
                    v-model="spec.length"
                    :min="0"
                    controls-position="right"
                    placeholder="长"
                    class="dimension-input"
                  />
                  <span class="separator">×</span>
                  <el-input-number
                    v-model="spec.width"
                    :min="0"
                    controls-position="right"
                    placeholder="宽"
                    class="dimension-input"
                  />
                  <span class="separator">×</span>
                  <el-input-number
                    v-model="spec.height"
                    :min="0"
                    controls-position="right"
                    placeholder="高"
                    class="dimension-input"
                  />
                </div>
              </div>

              <!-- 重量 -->
              <div class="spec-cell" style="width:18%">
                <div class="weight-group">
                  <el-input-number
                    v-model="spec.netWeight"
                    :min="0"
                    :precision="2"
                    controls-position="right"
                    placeholder="净重"
                    class="mb-2"
                  />
                  <el-input-number
                    v-model="spec.grossWeight"
                    :min="0"
                    :precision="2"
                    controls-position="right"
                    placeholder="毛重"
                  />
                </div>
              </div>

              <!-- 价格 -->
              <div class="spec-cell" style="width:16%">
                <div class="price-group">
                  <el-input-number
                    v-model="spec.costPrice"
                    :min="0"
                    :precision="2"
                    controls-position="right"
                    placeholder="成本价"
                    class="mb-2"
                  />
                  <el-input-number
                    v-model="spec.salePrice"
                    :min="0"
                    :precision="2"
                    controls-position="right"
                    placeholder="销售价"
                  />
                </div>
              </div>

              <!-- 操作 -->
              <div class="spec-cell" style="width:6%">
                <el-button
                  type="danger"
                  link
                  :disabled="goodsForm.specs.length === 1"
                  @click="removeSpec(index)"
                >
                  <el-icon><Delete /></el-icon>
                </el-button>
              </div>
            </div>
          </div>
        </div>
      </div>
    </el-form>

    <!-- 新增分类弹窗 -->
  <el-dialog
    v-model="dialogVisi"
    title="新增商品分类"
    width="500px"
    :close-on-click-modal="false"
  >
    <el-form 
      :model="formData" 
      label-width="120px"
      label-position="right"
    >
      <!-- 上级分类 -->
      <el-form-item label="上级分类">
        <el-cascader
          v-model="formData.parentId"
          :options="categoryOptions"
          :props="{ checkStrictly: true, label: 'name', value: 'id' }"
          clearable
          placeholder="不选择则创建根分类"
          style="width: 100%"
        />
      </el-form-item>

      <!-- 分类名称 -->
      <el-form-item 
        label="分类名称" 
        prop="name"
        :rules="[{ required: true, message: '分类名称不能为空' }]"
      >
        <el-input
          v-model="formData.name"
          placeholder="请输入商品分类名称"
          clearable
          maxlength="20"
          show-word-limit
        />
      </el-form-item>
    </el-form>

    <template #footer>
      <div class="dialog-footer">
        <el-button @click="dialogVisible = false">取消</el-button>
        <el-button 
          type="primary"
          @click="handleConfirm"
        >
          确定
        </el-button>
      </div>
    </template>
  </el-dialog>

      <template #footer>
        <div class="drawer-footer">
          <el-button @click="showGoodsDrawer = false">取消</el-button>
          <el-button type="primary" @click="submitGoodsForm">确定</el-button>
        </div>
      </template>

     
    </el-drawer>
  </div>
</template>

<script lang="ts" setup>
import { ref, reactive, nextTick,onMounted } from 'vue'
import { CirclePlus, Delete, Camera } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'

interface CategoryOption {
  id: number
  name: string
  children?: CategoryOption[]
}

// 弹窗显示状态
const dialogVisible = ref(false)
const dialogVisi= ref(false)
// 表单数据
const formData = reactive({
  parentId: null as number | null,
  name: ''
})

// 分类选项（示例数据）
const categoryOptions = ref<CategoryOption[]>([
  {
    id: 1,
    name: '家电',
    children: [
      { id: 11, name: '空调' },
      { id: 12, name: '冰箱' }
    ]
  },
  {
    id: 2,
    name: '数码',
    children: [
      { id: 21, name: '手机' },
      { id: 22, name: '电脑' }
    ]
  }
])

// 打开弹窗方法（供父组件调用）
const openDialog = (parentId?: number) => {
  formData.parentId = parentId || null
  // dialogVisible.value = true
  dialogVisible.value=true
}

// 确认提交
const handleConfirm = async () => {
  if (!formData.name.trim()) {
    ElMessage.error('请输入分类名称')
    return
  }

  try {
    // 这里添加实际提交逻辑
    console.log('提交数据:', formData)
    ElMessage.success('创建成功')
    // dialogVisible.value = false
    dialogVisi.value=false
    // 重置表单
    formData.name = ''
  } catch (error) {
    ElMessage.error('创建失败')
  }
}

// 暴露方法给父组件
defineExpose({ openDialog })
// 新增商品表单相关
const showGoodsDrawer = ref(false)
const categories = ref([
  { id: 1, name: '手机' },
  { id: 2, name: '家电' },
  { id: 3, name: '电脑' }
])

// 规格类型定义
interface GoodsSpec {
  name: string
  barcode: string
  length: number
  width: number
  height: number
  netWeight: number
  grossWeight: number
  costPrice: number
  salePrice: number
}

// 初始化规格模板
const initSpec = (): GoodsSpec => ({
  name: '',
  barcode: '',
  length: 0,
  width: 0,
  height: 0,
  netWeight: 0,
  grossWeight: 0,
  costPrice: 0,
  salePrice: 0
})

//商品表单数据
const goodsForm = reactive({
  name: '',
  category: '',
  goodsNo: '',
  brand: '',
  unit: '',
  brand: '',
  specs: [initSpec()] // 默认初始化一条规格
})



// 添加规格方法
const addSpec = () => {
  goodsForm.specs.push(initSpec())
  nextTick(() => {
    const container = document.querySelector('.spec-table')
    container?.scrollTo({
      top: container.scrollHeight,
      behavior: 'smooth'
    })
  })
}

// 删除规格方法
const removeSpec = (index: number) => {
  if (goodsForm.specs.length <= 1) {
    ElMessage.warning('至少需要保留一个规格')
    return
  }
  goodsForm.specs.splice(index, 1)
}

// 提交表单
const submitGoodsForm = () => {
  // 验证必填字段
  const hasEmpty = goodsForm.specs.some(spec => 
    !spec.name.trim() || !spec.barcode.trim()
  )
  
  if (hasEmpty) {
    ElMessage.error('请填写所有必填规格信息')
    return
  }
  
  console.log('提交数据:', goodsForm)
  showGoodsDrawer.value = false
}



// 修改原有的handleAddGoods方法
const handleAddGoods = () => {
  showGoodsDrawer.value = true
}

// 分类弹窗（示例方法）
const openCategoryDialog = (parentId?: number | null) => {
  formData.parentId = parentId || null
  dialogVisible.value = true
  dialogVisi.value=true
 }

interface CategoryNode {
  id: number
  name: string
  parentId?: number
  children?: CategoryNode[]
}

interface GoodsItem {
  id: number
  goodsInfo: string
  specs: string
  price: number
  weight: number
  dimensions: string
}

// 分类树数据
const categoryTree = ref<CategoryNode[]>([
  {
    id: 1,
    name: '手机',
    children: [
      { id: 11, name: '小米空调', parentId: 1 }
    ]
  },
  {
    id: 2,
    name: '打印机',
    children: [
      { id: 21, name: '小米打印机', parentId: 2 }
    ]
  }
])

// 分页相关
const currentPage = ref(1)
const pageSize = ref(10)
const total = ref(0)
const loading = ref(false)

// 搜索表单
const searchForm = reactive({
  goodsNo: '',
  goodsName: '',
  brand: ''
})

const brandOptions = [
  { label: '小米', value: 'xiaomi' },
  { label: '华为', value: 'huawei' },
  { label: '苹果', value: 'apple' }
]

// 模拟数据
const mockData = Array.from({ length: 85 }, (_, i) => ({
  id: i + 1,
  goodsInfo: `商品 ${i + 1}`,
  specs: '规格',
  price: 1000 + i * 100,
  weight: 1.0 + i * 0.1,
  dimensions: '100 × 100 × 30'
}))

const goodsList = ref<GoodsItem[]>([])

// 获取数据方法
const fetchGoodsList = async () => {
  loading.value = true
  try {
    // 模拟API请求
    await new Promise(resolve => setTimeout(resolve, 500))
    
    // 分页处理
    const start = (currentPage.value - 1) * pageSize.value
    const end = start + pageSize.value
    goodsList.value = mockData.slice(start, end)
    total.value = mockData.length
  } finally {
    loading.value = false
  }
}

// 分页事件
const handlePageChange = (val: number) => {
  currentPage.value = val
  fetchGoodsList()
}

const handleSizeChange = (val: number) => {
  pageSize.value = val
  currentPage.value = 1
  fetchGoodsList()
}

// 分类操作
// 父组件脚本部分
const handleAddRootCategory = () => {
  formData.parentId = null
  formData.name = ''
  dialogVisi.value = true
}
const handleAddSubCategory = (data: CategoryNode) => {
  openCategoryDialog(data.id)
 }
const handleDeleteCategory = (data: CategoryNode) => console.log('删除分类', data)
const handleEditCategory = (data: CategoryNode) => console.log('编辑分类', data)

// 商品操作
const handleSearch = async () => {
  currentPage.value = 1
  await fetchGoodsList()
}

const handleReset = () => {
  Object.assign(searchForm, {
    goodsNo: '',
    goodsName: '',
    brand: ''
  })
  currentPage.value = 1
  fetchGoodsList()
}

const handleDeleteGoods = (row: GoodsItem) => console.log('删除商品', row)
const handleEditGoods = (row: GoodsItem) => console.log('编辑商品', row)

// 初始化加载
onMounted(() => {
  fetchGoodsList()
})
</script>

<style scoped lang="scss">
.container {
  display: flex;
  min-height: 100vh;
  background: #f5f7f9;
}

.sidebar {
  width: 280px;
  background: white;
  padding: 16px;
  border-right: 1px solid #e4e7ed;
  overflow-y: auto;
}

.content {
  flex: 1;
  padding: 16px;
  overflow-x: hidden;
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e4e7ed;
  
  .title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #303133;
  }
}

.category-node {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 6px 0;
  transition: background-color 0.2s;
  
  &:hover {
    background-color: #f5f7fa;
  }
  
  .node-label {
    flex: 1;
    margin-right: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .category-actions {
    opacity: 0;
    transition: opacity 0.2s;
    
    .el-button {
      margin-left: 8px;
    }
  }
  
  &:hover .category-actions {
    opacity: 1;
  }
}

.header {
  background: white;
  padding: 16px;
  border-radius: 4px;
  margin-bottom: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  
  .search-form {
    margin-bottom: 16px;
    
    :deep(.el-form-item) {
      margin-bottom: 12px;
    }
  }
  
  .action-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
  }
}

:deep(.table-header) th {
  background-color: #f8fafc !important;
  font-weight: 600;
  color: #606266;
}

.el-table {
  background: white;
  border-radius: 4px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  
  :deep(.el-button) {
    padding: 4px 8px;
  }
}

.pagination-container {
  margin-top: 20px;
  padding: 16px;
  background: white;
  border-radius: 4px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 1200px) {
  .container {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #e4e7ed;
  }
  
  .content {
    overflow: visible;
  }
}

@media (max-width: 768px) {
  .pagination-container {
    overflow-x: auto;
  }
  
  :deep(.el-pagination__jump) {
    display: none !important;
  }
}

/* 新增表单样式 */
.form-section {
  margin-bottom: 24px;
  padding: 16px;
  background: #f8fafc;
  border-radius: 4px;
}

.section-title {
  margin: 0 0 16px 0;
  color: #606266;
  font-size: 15px;
}

.spec-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.spec-table {
  border: 1px solid #ebeef5;
  border-radius: 4px;
}

.spec-header-row {
  padding: 12px;
  background: #f5f7fa;
  font-size: 13px;
  color: #909399;
}

.spec-item {
  padding: 12px;
  border-bottom: 1px solid #ebeef5;
  
  &:last-child {
    border-bottom: none;
  }
}

.dimension-inputs,
.weight-inputs,
.price-inputs {
  display: flex;
  align-items: center;
  gap: 4px;
  
  .separator {
    color: #c0c4cc;
    padding: 0 2px;
  }
}

:deep(.el-input-number) {
  width: 80px;
  
  &.is-controls-right .el-input__wrapper {
    padding-left: 5px;
    padding-right: 25px;
  }
}

.drawer-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 0 20px;
}

.goods-form {
  padding: 20px;
}

/* 规格表格样式 */
.spec-table {
  max-height: 60vh;
  overflow-y: auto;
  border: 1px solid #ebeef5;
  border-radius: 8px;
}

.spec-header-row {
  padding: 12px;
  background: #f5f7fa;
  font-size: 13px;
  color: #909399;
}

.spec-item {
  padding: 12px;
  border-bottom: 1px solid #ebeef5;
  transition: background-color 0.3s;
  
  &:hover {
    background-color: #fafafa;
  }
  
  &:last-child {
    border-bottom: none;
  }
}

/* 输入组件样式 */
.dimension-inputs,
.weight-inputs,
.price-inputs {
  display: flex;
  gap: 8px;
  align-items: center;
  
  :deep(.el-input-number) {
    width: 100px;
    
    .el-input__wrapper {
      padding-left: 5px;
      padding-right: 5px;
    }
  }
}

.separator {
  color: #c0c4cc;
  padding: 0 2px;
}

/* 验证样式 */
.required {
  color: #f56c6c;
  margin-left: 2px;
}

.is-error {
  :deep(.el-input__wrapper) {
    background-color: #fef0f0;
    border-color: #f56c6c !important;
  }
}

/* 间距调整 */
.mt-2 {
  margin-top: 8px;
}

.goods-drawer {
   /* 调整抽屉内部布局 */
  :deep(.el-drawer__body) {
    padding: 20px;
    height: calc(100% - 60px);
    overflow-y: auto;
  }
}

.spec-section {
  margin-top: 24px;
  border: 1px solid #ebeef5;
  border-radius: 8px;

  .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid #ebeef5;
    
    .section-title {
      margin: 0;
      font-size: 14px;
      font-weight: 600;
      color: #303133;
    }
  }
}

.spec-container {
  padding: 12px;

  .spec-header {
    display: flex;
    padding: 8px 0;
    background: #f8fafc;
    border-radius: 4px;
    margin-bottom: 8px;

    .header-item {
      padding: 0 12px;
      font-size: 13px;
      color: #606266;
      font-weight: 500;
    }
  }
}

.spec-body {
  .spec-row {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #ebeef5;

    &:last-child {
      border-bottom: none;
    }

    .spec-cell {
      padding: 0 12px;

      .dimension-group {
        display: flex;
        align-items: center;
        gap: 4px;

        .dimension-input {
          width: 80px;
          
          :deep(.el-input__wrapper) {
            padding-left: 8px;
            padding-right: 8px;
          }
        }

        .separator {
          color: #c0c4cc;
          font-size: 12px;
        }
      }

      .barcode-group,
      .weight-group,
      .price-group {
        .el-input,
        .el-input-number {
          width: 100%;
        }
      }
    }
  }
}

 /* 统一输入框样式 */
:deep(.el-input-number) {
  &.is-controls-right {
    .el-input__wrapper {
      padding-right: 32px;
    }
  }
  
  .el-input__inner {
    text-align: left;
  }
}

 /* 响应式处理 */
@media (max-width: 768px) {
  .goods-drawer {
    width: 100% !important;
  }
  
  .spec-container {
    .spec-header,
    .spec-row {
      flex-wrap: wrap;
      
      .header-item,
      .spec-cell {
        width: 100% !important;
        margin-bottom: 8px;
      }
    }
  }
}

/* 弹窗底部按钮右对齐 */
.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* 输入框宽度适配 */
:deep(.el-input) {
  width: 100%;
}

/* 分类选择器样式优化 */
:deep(.el-cascader) {
  width: 100%;
}
</style>